﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Vkontakte.Api.Operations;

namespace VkClientIM.Logic
{
	public class Conversation
	{
		private Profile _buddy;
		private Profile _myProfile;
		private ObservableCollection<Message> _messages=new ObservableCollection<Message>();


		public Conversation(Profile my, Profile p)
		{
			_myProfile = my;
			_buddy = p;
		}

		public Profile Buddy
		{
			get { return _buddy; }
		}
		
		public Profile MyProfile
		{
			get { return _myProfile; }
		}

		public NotifyCollectionChangedProxy<ObservableCollection<Message>, Message> Messages
		{
			get { return new NotifyCollectionChangedProxy<ObservableCollection<Message>, Message>(_messages); }
		}

		internal void AddMessage(Message msg)
		{
			_messages.Add(msg);
		}

		public void SendMessage(string message)
		{

			var q=new MessagesSend();
			q.MessageType = MessageType.Chat;
			q.UserID = _buddy.UserID;
			q.Message = message;
			q.Completed += delegate
			               	{

			               	};
			App.Current.ApiClient.ExecuteHighPriorityQuerry(q);
		}
	}


	public interface IConversationWindow
	{
		bool IsConversationOpened(Conversation c);
		void LoadConversation(Conversation c);
		void Show();
	}
}
